<script type="text/javascript">
function show_this(hidden_div)
{
	$("#"+hidden_div).css({'visibility':'visible'});
}
function hide_this(hidden_div)
{
	$("#"+hidden_div).css({'visibility':'hidden'});
}
function bulk(param)
{
	var ids = $("input[name='wishlist_id[]']").serialize();
	
	if (ids)
	{
		$.ajax({
			type: "POST",
			url: "<?php echo site_url().'backend/wishlist/ajax_bulk_action/' ?>"+param,
			data: ids,
			success: function(data){
				window.location.reload();
				$(":checkbox").removeAttr("checked");
			}
		});
	}
}
//jQuery
$(function(){
	$(".check_all").click(function(){
		var checked_status = this.checked;
		$(":checkbox").each(function()
		{
		this.checked = checked_status;
		});
	});
	setTimeout(function(){
	  $("#kotak").fadeOut("slow", function(){
		$("#kotak").remove();
	  });    
	}, 3000);
	
	$("#sort_wishlist").change(function(){
		var sort = this.value;
		//alert(lang_id+base_url);
		window.location="<?php echo site_url().'backend/wishlist/sort_wishlist/' ?>"+sort;
	})
});
</script>
<div class="left"></div>
<div class="right"></div>
<div class="heading">
	<h1 style="background-image: url('<?php echo base_url()?>assets/images/product.png');">Wishlist</h1>
</div>
<div class="wrapper">
<h1>Wishlist List</h1>
<div class="table_filter_wrapper">
	<input type="button" onclick="bulk('delete')" value="Hapus">
	<div style="float:right;display:inline-block;">Filter: 
		<?php 
		$attr = 'id="sort_wishlist" style="width:200px;"';
		$options = array(
				  'desc' => 'Urut Terbaru',
				  'asc'=> 'Urut Terlama'
				);
		echo form_dropdown('sort_wishlist', $options, $this->session->userdata('sort_wishlist'), $attr);
		?>
	</div><br>
	<?php echo $this->session->flashdata('message_type');?>
</div>
<table>
	<thead>
		<tr>
			<th style="width:0%" ><input class="check_all" type="checkbox" ></th>
			<th style="width:0%" >No</th>
			<th style="width:10%">Tanggal</th>
			<th style="width:20%">Member</th>
			<th style="width:20%">Product</th>
			<th style="width:50%">Keterangan</th>
		</tr>
	</thead>
	<?php
		$no = 1 + $urut;
		foreach($res as $row):
	?>
	<tr class="<?php if ($no %2 == 0) echo 'even';?>">
		<td><input type="checkbox" name="wishlist_id[]" value="<?php echo $row->wishlist_id?>"></td>
		<td><?php echo $no;?></td>
		<td><?php echo formatDate($row->date_added,'short');?></td>
		<td onMouseOver="show_this('action-<?php echo $row->wishlist_id;?>')" onMouseOut="hide_this('action-<?php echo $row->wishlist_id; ?>')">
			<b><?php echo anchor('backend/wishlist/view/'.$row->wishlist_id, get_member_data($row->member_id,'nama'));?></b>
			<div id="action-<?php echo $row->wishlist_id?>" class="action invisible">
			<?php echo anchor('backend/wishlist/view/'.$row->wishlist_id,'View')?> |
			<?php echo anchor('backend/wishlist/delete/'.$row->wishlist_id,'Delete',array('onclick' => "return confirm('Anda yakin menghapus data ini?')"))?>
			</div>
		</td>
		<td><?php echo get_produk_data($row->produk_id,'nama_produk');?></td>
		<td><?php echo word_limiter($row->keterangan,10);?></td>
	</tr>
	<?php
	 	$no++;
		endforeach;
	?>
</table>
<?php if($this->pagination->create_links()==TRUE):?>
<p id="pagination">Halaman : <?php echo $this->pagination->create_links(); ?></p>
<?php endif; ?>
</div>
